//
//  AddSearchModel.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/9/5.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "AddSearchModel.h"

@implementation AddSearchModel

+(instancetype)modelWithDictionary:(NSDictionary *)dic{
    
    AddSearchModel *model =[[AddSearchModel alloc] init];
    
    [model setValuesForKeysWithDictionary:dic];
    
    return model;
}


+(void)with:(NSString* )string addSearchWithSucess:(void(^)(NSArray<AddSearchModel *> *array))sucessBlock error:(void(^)())errorBlock{
    
        NSDictionary * parameters = @{@"keyword":string};
    
    [[NetworkTool sharedTools] POST:@"symbols/search" parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *  _Nullable responseObject) {
        
        NSArray * paramArray = responseObject[@"param"];
        
        //        NSLog(@"==%@",paramArray);
        
        NSMutableArray *mArray = [NSMutableArray array];
        
        [paramArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            
            AddSearchModel * model = [AddSearchModel modelWithDictionary:obj];
            
            [mArray addObject:model];
            
        }];
        
        if(sucessBlock){
            sucessBlock(mArray.copy);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
    
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
}

@end
